package org.looop.chuck.parser;

import java.io.InputStream;
import java.io.InputStreamReader;

import org.w3c.dom.Document;
import org.w3c.tidy.Tidy;

public abstract class TidyHTMLParser implements HTMLParser {

	@Override
	public boolean parseDOM(InputStream in)
			throws Exception {
		Tidy tidy = new Tidy();
		tidy.setQuiet(true);
		tidy.setShowWarnings(false);
		Document root = tidy.parseDOM(new InputStreamReader(in, "utf-8"), null);
		return onDomReady(root);
	}
	
	public abstract boolean onDomReady(Document root) throws Exception;

}
